﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Soundteller.Audio.Model.Interfaces;
using Soundteller.Audio.Repositories;
using Soundteller.Audio.Repositories.Interfaces;
using Soundteller.Common.Tests;

namespace Soundteller.Audio.Tests.Unit.Repositories.BeatRepositorySpecifications
{
    public abstract class WhenGet : TestBase
    {
        protected IBeatRepository BeatRepository { get; private set; }
        protected Mock<IMemoryContext> Context { get; private set; }

        protected double? Result { get; private set; }

        protected override void Arrange()
        {
            Context = new Mock<IMemoryContext>();
            BeatRepository = new BeatRepository(Context.Object);
        }

        protected override void Act()
        {
            Result = BeatRepository.Get();
        }
    }

    [TestClass]
    public class WhenGetGivenBeatIsEmpty : WhenGet
    {
        protected override void Arrange()
        {
            base.Arrange();
            Context.Setup(c => c.CurrentBeat).Returns((double?)null);
        }

        [TestMethod]
        public void ThenResultShouldBeEmpty()
        {
            Assert.IsNull(Result);
        }
    }

    [TestClass]
    public class WhenGetGivenBeatIsThirteen : WhenGet
    {
        protected override void Arrange()
        {
            base.Arrange();
            Context.Setup(c => c.CurrentBeat).Returns(13);
        }

        [TestMethod]
        public void ThenResultShouldBeThirteen()
        {
            Assert.AreEqual(13, Result);
        }
    }
}
